﻿using Outdoors.Helpers.Foursquare;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Outdoors.ViewModels
{
    public class PlaceViewModel : INotifyPropertyChanged
    {
        public ObservableCollection<PlaceItemViewModel> Items { get; private set; }
        public PlaceViewModel()
        {
            this.Items = new ObservableCollection<PlaceItemViewModel>();
        }

        public bool IsDataLoaded
        {
            get;
            private set;
        }
        public void LoadData(List<FoursquareVenue> venues)
        {
            foreach (var venue in venues)
            {
                var item = new PlaceItemViewModel()
                {
                    Name = venue.VenueName,
                    Information = venue.CheckIns.ToString(),
                    Distance = venue.Distance,
                    Latitude = venue.Latitude,
                    Longitude = venue.Longitude
                };

                Items.Add(item);
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
